﻿
DECLARE @RootId bigint
DECLARE @ParentId bigint
DECLARE @Id bigint

INSERT INTO DirectoryEntry(Name, ParentId, CreatedOn, UpdatedOn, [Type])
VALUES('', NULL, GETUTCDATE(), GETUTCDATE(), 2)

SET @RootId = @@IDENTITY

INSERT INTO AccessControlList(DirectoryEntryId, [Role], [Permission])
VALUES(@RootId, 'All', 1)

INSERT INTO DirectoryEntry(Name, ParentId, CreatedOn, UpdatedOn, [Type])
VALUES('Assemblies', @RootId, GETUTCDATE(), GETUTCDATE(), 2)

INSERT INTO AccessControlList(DirectoryEntryId, [Role], [Permission])
VALUES(@@IDENTITY, 'All', 1)

INSERT INTO DirectoryEntry(Name, ParentId, CreatedOn, UpdatedOn, [Type])
VALUES('Services', @RootId, GETUTCDATE(), GETUTCDATE(), 2)

INSERT INTO AccessControlList(DirectoryEntryId, [Role], [Permission])
VALUES(@@IDENTITY, 'All', 1)

INSERT INTO DirectoryEntry(Name, ParentId, CreatedOn, UpdatedOn, [Type])
VALUES('Workflows', @RootId, GETUTCDATE(), GETUTCDATE(), 2)

INSERT INTO AccessControlList(DirectoryEntryId, [Role], [Permission])
VALUES(@@IDENTITY, 'All', 1)

INSERT INTO DirectoryEntry(Name, ParentId, CreatedOn, UpdatedOn, [Type])
VALUES('Processes', @RootId, GETUTCDATE(), GETUTCDATE(), 2)

INSERT INTO AccessControlList(DirectoryEntryId, [Role], [Permission])
VALUES(@@IDENTITY, 'All', 1)

INSERT INTO DirectoryEntry(Name, ParentId, CreatedOn, UpdatedOn, [Type])
VALUES('Processors', @RootId, GETUTCDATE(), GETUTCDATE(), 2)

INSERT INTO AccessControlList(DirectoryEntryId, [Role], [Permission])
VALUES(@@IDENTITY, 'All', 1)

INSERT INTO DirectoryEntry(Name, ParentId, CreatedOn, UpdatedOn, [Type])
VALUES('Sets', @RootId, GETUTCDATE(), GETUTCDATE(), 2)

SET @ParentId = @@IDENTITY

INSERT INTO AccessControlList(DirectoryEntryId, [Role], [Permission])
VALUES(@ParentId, 'All', 1)

INSERT INTO DirectoryEntry(Name, ParentId, CreatedOn, UpdatedOn, [Type])
VALUES('Shared', @ParentId, GETUTCDATE(), GETUTCDATE(), 2)

SET @Id = @@IDENTITY

INSERT INTO AccessControlList(DirectoryEntryId, [Role], [Permission])
VALUES(@Id, 'Application', 1)

INSERT INTO AccessControlList(DirectoryEntryId, [Role], [Permission])
VALUES(@Id, 'Processor', 1)

INSERT INTO DirectoryEntry(Name, ParentId, CreatedOn, UpdatedOn, [Type])
VALUES('Local', @ParentId, GETUTCDATE(), GETUTCDATE(), 2)

SET @Id = @@IDENTITY

INSERT INTO AccessControlList(DirectoryEntryId, [Role], [Permission])
VALUES(@Id, 'Application', 1 | 4)

INSERT INTO AccessControlList(DirectoryEntryId, [Role], [Permission])
VALUES(@Id, 'Processor', 1 | 4)

INSERT INTO DirectoryEntry(Name, ParentId, CreatedOn, UpdatedOn, [Type])
VALUES('Roles', @RootId, GETUTCDATE(), GETUTCDATE(), 2)

SET @ParentId = @@IDENTITY

INSERT INTO AccessControlList(DirectoryEntryId, [Role], [Permission])
VALUES(@ParentId, 'All', 1)

INSERT INTO DirectoryEntry(Name, ParentId, CreatedOn, UpdatedOn, [Type])
VALUES('Administrator', @ParentId, GETUTCDATE(), GETUTCDATE(), 64)

INSERT INTO RoleUser(DirectoryEntryId, UserName)
VALUES (@@IDENTITY, '/*--DefaultAdmin--*/')

INSERT INTO DirectoryEntry(Name, ParentId, CreatedOn, UpdatedOn, [Type])
VALUES('Processor', @ParentId, GETUTCDATE(), GETUTCDATE(), 64)

INSERT INTO DirectoryEntry(Name, ParentId, CreatedOn, UpdatedOn, [Type])
VALUES('Application', @ParentId, GETUTCDATE(), GETUTCDATE(), 64)
